proc place_macro {args} {
	parse_proc_arguments -args ${args} arg
	#set check_args "0b00000000"
	if {[info exist arg(-macros)] && (${arg(-macros)} ne "")} {
		set macros ${arg(-macros)}
	} else { return "error argumens,please specify correct macros list" }
	if {[info exist arg(-num)] && (${arg(-num)} ne "")} {
		set num ${arg(-num)}
	} else { return "error argumens,please specify correct number" }
	if {[info exist arg(-startX)] && ({$arg(-startX)} ne "")} {
		set startX ${arg(-startX)}
	} else { return "error argumens,please specify correct coordinate of start point" }
	if {[info exist arg(-startY)] && (${arg(-startY)} ne "")} {
		set startY ${arg(-startY)}
	} else { return "error argumens,please specify correct coordinate of start point" }
	if {[info exist arg(-spaceX)] && (${arg(-spaceX)} ne "")} {
		set spaceX ${arg(-spaceX)}
	} else { return "error argumens,please specify correct X space between 2 macros" }
	if {[info exist arg(-spaceY)] && (${arg(-spaceY)} ne "")} {
		set spaceY ${arg(-spaceY)}
	} else { return "error argumens,please specify correct Y space between 2 macros" }
	if {[info exist arg(-orientation)] && (${arg(-orientation)} ne "")} {
		set orientation ${arg(-orientation)}
	} else { return "error argumens,please specify correct orientation of macro" }
	if {[info exist arg(-flag)] && (${arg(-flag)} ne "")} {
		set flag ${arg(-flag)}
	} else { return "error argumens,please specify correct flag" }

	set n 0
	set maxHeight 0
	set maxWidth 0
	set x ${startX} ; set y ${startY}
	foreach i ${macros} {
		# get per macro's width and height
		set instX [get_db [get_db inst:${i}] .bbox.width ]
		set instY [get_db [get_db inst:${i}] .bbox.length ]
		if {${instY} >= ${maxHeight}} {set maxHeight ${instY}}
		if {${instX} >= ${maxWidth}} {set maxWidth ${instX}}
		if {${flag}} {
			placeInstance ${i} ${x} ${y} -placed ${orientation}
			incr n
			if {${n}%${num} == 0} {
				set x ${startX} ; set y [expr ${y} + ${maxHeight} + ${spaceY}]
				set startY ${y}
			} else {
				set x [expr ${x} + ${instX} + ${spaceX}] ; set y ${startY}
			}
		} else {
			placeInstance $i [expr ${x} - ${instX}] ${y} -placed ${orientation}
			incr n
			if {${n}%${num} == 0} {
				set x ${startX} ; set y [expr ${y} + ${maxHeight} + ${spaceY}]
				set startY ${y}
			} else {
				set x [expr ${x} - ${instX} - ${spaceX}] ; set y ${startY}
			}			
		}
	}
}

define_proc_arguments place_macro \
	-info "place macros using user specified way" \
	-define_args {
	{-macros "specify insts need to be placed" "" list required} \
	{-num "the number of insts in a row" "" int required} \
	{-startX "start point X coordinate" "" float required} \
	{-startY "start point Y coordinate" "" float required} \
	{-spaceX "X interval of insts" "" float required} \
	{-spaceY "Y interval of insts" "" float required} \
	{-orientation "orientation of insts" "" string required} \
	{-flag "control place direction,o is from right to left" "" string required} \
}